package com.fpswork.Helper;

import java.sql.SQLException;

import org.springframework.jdbc.core.JdbcTemplate;
/**
 * 获取数据库类型
 * @author spf
 */

public class DBProductUtil {
	private static DBProductUtil util;
	
	private static String productName ;
	
	private DBProductUtil() {}
	
	
	public static DBProductUtil getInstance(JdbcTemplate jdbcTemplate) {
		if(util == null) {
			try {
				productName = jdbcTemplate.getDataSource().getConnection().getMetaData().getDatabaseProductName();
			} catch (SQLException e) {
				e.printStackTrace();
			}  
			util = new DBProductUtil();
		}
		return util;
	}
	
	@SuppressWarnings("static-access")
	public static String getProductName(){
		return util.productName;
	}
	
}
